function getURLparameters(){
    
    var browser = navigator.userAgent;
    var ret = "browser="+browser    

    //check for the other params
	var loc = window.location.href
	var index = loc.indexOf('?')
	var b=""
	if(index>-1){  
		b= loc.substring(loc.indexOf('?')+1)
	}
    if(b!=""){
        ret = ret+"&"+b	    
    }
    return ret;
}

var urlParams = getURLparameters();

//
// This method Gets URL Parameters (GUP)
//
function gupURL( name, URL )
{
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( URL );
  if( results == null )
    return "";
  else
    return results[1];
}

//
// This method decodes the query parameters that were URL-encoded
//

/*
function decode(strToDecode)
{
  var encoded = strToDecode;
  return unescape(encoded.replace(/\+/g,  " "));
}
*/
    
function submitForm(sandbox, URL){
    var f= document.createElement('form')
    f.id="mturk_form"
    f.method="POST"
    f.action="http://www.mturk.com/mturk/externalSubmit"    
    if (sandbox) {
        f.action = "http://workersandbox.mturk.com/mturk/externalSubmit";
    }    
    
    var b= document.createElement('input')
    b.id="submitButton"
    b.type="hidden" 
    b.name="default" 
    b.value="1234"
    
    var h= document.createElement('input')
    h.id="assignmentId"
    h.type="hidden" 
    h.name="assignmentId" 
    h.value= gupURL('assignmentId', URL);
    
    f.appendChild(h)
    f.appendChild(b)
            
    document.body.appendChild(f)
    
    f.submit();
}